precision lowp float;
varying vec2 vTextureCoord;
uniform float iTime;
uniform sampler2D uMaskTex;
uniform sampler2D uNoise;
uniform sampler2D uSampler;


float luminace(vec3 c){
    return  0.2125*c.r+0.7154*c.g+0.0721*c.b;
}

void main(void) {
    float gray = clamp(iTime/3.0,0.,1.);
    gray = 0.91;
    vec4 col = texture2D(uSampler, vTextureCoord);
    vec4 mask = texture2D(uMaskTex, vTextureCoord);
    float threshold = luminace(mask.rgb);
    float light = smoothstep(0.,1.,luminace(col.rgb) * (1.0-threshold));
    col = col*threshold;
    gl_FragColor = smoothstep(0.,1.,col+light*gray);
    gl_FragColor.a = 1.0;
}